package net.gaox;

import net.gaox.entrty.BankAccount;
import net.gaox.service.BankInterface;
import net.gaox.service.impl.BankInterfaceImpl;

import java.math.BigDecimal;

/**
 * <p> 银行功能 </p>
 *
 * @author gaox·Eric
 * @date 2021/11/11 21:58
 */
public class Bank {
    public static void main(String[] args) {
        BankInterface bankInterface = new BankInterfaceImpl();
        // 银行卡号1
        String accountNumber1 = "62170001";
        // 银行卡号2
        String accountNumber2 = "62170002";

        // 注册
        bankInterface.register(1L, accountNumber1, "高点点");
        BankAccount bankAccount1 = bankInterface.getBankAccount(accountNumber1);
        System.out.println(bankAccount1);

        // 存钱
        Boolean addMoney1 = bankInterface.addMoney(accountNumber1, new BigDecimal(1000));
        if (null == addMoney1) {
            System.out.println("银行卡不能存在！");
        } else {
            if (addMoney1) {
                System.out.println("存钱成功");
            } else {
                System.out.println("存钱失败");
            }
        }

        // 取钱-正常
        Boolean subMoney11 = bankInterface.subMoney(accountNumber1, new BigDecimal(900));
        if (null == subMoney11) {
            System.out.println("银行卡不能存在！");
        } else {
            if (subMoney11) {
                System.out.println("取钱成功");
            } else {
                System.out.println("取钱失败");
            }
        }

        // 查询
        BankAccount bankAccount11 = bankInterface.getBankAccount(accountNumber1);
        System.out.println(bankAccount11);

        // 取钱-异常
        Boolean subMoney12 = bankInterface.subMoney(accountNumber1, new BigDecimal(200));
        if (null == subMoney12) {
            System.out.println("银行卡不能存在！");
        } else {
            if (subMoney12) {
                System.out.println("取钱成功");
            } else {
                System.out.println("取钱失败");
            }
        }

        // 查询
        BankAccount bankAccount12 = bankInterface.getBankAccount(accountNumber1);
        System.out.println(bankAccount12);

        // 取钱
        Boolean subMoney13 = bankInterface.subMoney(accountNumber1, new BigDecimal(100));
        if (null == subMoney13) {
            System.out.println("银行卡不存在！");
        } else {
            if (subMoney13) {
                System.out.println("取钱成功");
            } else {
                System.out.println("取钱失败");
            }
        }

        // 注销
        Boolean cancel = bankInterface.cancel(accountNumber1);
        if (null == cancel) {
            System.out.println("银行卡不能存在！");
        } else {
            if (cancel) {
                System.out.println("注销成功");
            } else {
                System.out.println("注销失败");
            }
        }

        // 取钱
        Boolean addMoney12 = bankInterface.addMoney(accountNumber1, new BigDecimal(100));
        if (null == addMoney12) {
            System.out.println("银行卡不能存在！");
        } else {
            if (addMoney12) {
                System.out.println("存钱成功");
            } else {
                System.out.println("存钱失败");
            }
        }

        // 查询
        BankAccount bankAccount13 = bankInterface.getBankAccount(accountNumber1);
        System.out.println(bankAccount13);
        // 查询
        BankAccount bankAccount21 = bankInterface.getBankAccount(accountNumber2);
        System.out.println(bankAccount21);
    }
}
